/**
 * create by zqk on 2018/4/23.
 */

var iScheduleType = 2;
var userList;
var defaultDate;
var postData;
var iUserId;
$.fn.pagination.defaults.displayMsg = '';
$(document).ready(function(){
    getSchedule();
});

function getSchedule(){
    $.post(moduleUrl + 'Schedule/getHomeSchedule', function(result){
        $('#calendar').fullCalendar( 'destroy');
        fullCalendarData(result);
    }, 'json')
    return false;
}

function fullCalendarData(listData) {
    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'listDay,listWeek,month,listMonth'
        },
        views: {
            listDay: { buttonText: '天' },
            listWeek: { buttonText: '周' }
        },
        // height:'100%',
        height : window.innerHeight-30,
        windowResize: function(view) {
            $('#calendar').fullCalendar('option', 'height', window.innerHeight-26);
        },
        defaultView: 'month',
        navLinks: true, // can click day/week names to navigate views
        editable: true,
        locale:'zh-cn',
        defaultDate: defaultDate,
        eventLimit: true, // allow "more" link when too many events
        dayClick: function(date, allDay, jsEvent, view) {
            var url = moduleUrl + 'Schedule/addScheduleForm?iUserId='+iUserId;
            window.top.xhTop.showModal({
                title: '添加日程',
                width:480,
                content: '<iframe frameborder="0" style="width: 100%;height:400px;" src="' + url + '"></iframe>',

            });
        },
        eventClick: function(event, jsEvent, view) {
            var url = moduleUrl + 'Schedule/addScheduleForm?iScheduleId='+event.id;
            window.top.xhTop.showModal({
                title: '修改日程',
                width:480,
                content: '<iframe frameborder="0" style="width: 100%;height:445px;" src="' + url + '"></iframe>',
            });
        },
        events:listData
    });


}